package com.example.service;

import com.example.entity.TaskTime;
import com.example.mapper.TaskTimeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
帖子业务处理
 */
@Service
public class TaskTimeService {

    @Resource
    private TaskTimeMapper taskTimeMapper;

    public void add(TaskTime taskTime) {
        taskTimeMapper.insert(taskTime);
    }

    public void deleteById(Integer id) {
        taskTimeMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(TaskTime taskTime) {
        taskTimeMapper.updateById(taskTime);
    }

    public TaskTime selectById(Integer id) {
        return taskTimeMapper.selectById(id);
    }

    public List<TaskTime> selectAll(TaskTime taskTime) {
        return taskTimeMapper.selectAll(taskTime);
    }

    public PageInfo<TaskTime> selectPage(TaskTime taskTime, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<TaskTime> taskTimeList = taskTimeMapper.selectAll(taskTime);
        return PageInfo.of(taskTimeList);
    }
}
